import { MathUtils } from "../../api/math/MathUtils";
import { ITimer } from "../../api/timer/ITimer";
import { TimerUtils } from "../../api/timer/TimerUtils";
import { E_TimeConfig } from "../defs/com/E_TimeConfig";
import { E_StageGlobal } from "../defs/stage/E_StageGlobal";
import { CDStageGlobal } from "../excel/CDStageGlobal";
import { CEStage } from "../excel_extend/CEStage";
import { Player } from "../struct/Player";
import { SDServer } from "./SDServer";


/**
 * 数据-世界boss3
 */
export abstract class SDWorldBoss3 {

    /**
     * 获取boss的战斗场景id
     * @param player 
     * @param time 
     * @returns 
     */
    public static getStageConfigId(player: Player, time = ITimer.getServerTime()): number {
        const count = 7;
        const ct = SDServer.getServerCreateTime(player);
        const st = TimerUtils.getDayZeroTime(ct);
        const zt = TimerUtils.getDayZeroTime(time);
        const day = Math.floor((zt - st) / E_TimeConfig.Day);
        const idx = MathUtils.clamp(day % count, 0, count - 1);
        const stageId = CEStage.worldBossStage3.getKeys()[idx];
        return stageId;
    }

    /**
     * 挑战结束时间
     * @param nowTime
     * @returns
     */
    public static getChallengeEndTime(nowTime = ITimer.getServerTime()): number {
        const zt = TimerUtils.getDayZeroTime(nowTime);
        const h = CDStageGlobal.getData(E_StageGlobal.WorldBossChallengeEndTime).value;
        const countPoint = E_TimeConfig.Hour * h;
        return zt + countPoint;
    }



}
